package com.research.performace.entities;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "tblinvoices")
public class Invoice {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private Long id;
	
	@Column(name = "PublicNumber")
	private String publicNumber = "";
	
	@Column(name = "Notes")
	private String notes = "";
	
	@Column(name = "Balance")
	private Float balance = 0.0f;
	
	@Column(name = "PaymentDate")
	private Date paymentDat = new Date();
	
	@Column(name = "Status")
	private Integer status = 0;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CustomerID")
	private Customer customer;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PaymentRequestID")
	private PaymentRequest paymentRequest;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CurrencyID")
	private Currency currency;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "invoice")
	private List<InvoiceLine> lines;

	/**
	 * Constructor
	 */
	public Invoice() { }

	/**
	 * Constructor
	 * @param publicNumber
	 * @param notes
	 * @param balance
	 * @param paymentDat
	 * @param status
	 */
	public Invoice(String publicNumber, String notes, Float balance,
			Date paymentDat, Integer status) {
		this.publicNumber = publicNumber;
		this.notes = notes;
		this.balance = balance;
		this.paymentDat = paymentDat;
		this.status = status;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getPublicNumber() {
		return publicNumber;
	}

	public void setPublicNumber(String publicNumber) {
		this.publicNumber = publicNumber;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Float getBalance() {
		return balance;
	}

	public void setBalance(Float balance) {
		this.balance = balance;
	}

	public Date getPaymentDat() {
		return paymentDat;
	}

	public void setPaymentDat(Date paymentDat) {
		this.paymentDat = paymentDat;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public List<InvoiceLine> getLines() {
		return lines;
	}

	public void setLines(List<InvoiceLine> lines) {
		this.lines = lines;
	}
	
}
